package org.beetl.sql.ext.jpa.mapper.internal.jpa;

import java.lang.reflect.Method;
import java.util.List;

import org.beetl.sql.clazz.kit.BeetlSQLException;
import org.beetl.sql.core.SQLManager;
import org.beetl.sql.mapper.MapperInvoke;

public class SaveAllAndFlushAMI extends MapperInvoke{

	@Override
	public Object call(SQLManager sm, Class entityClass, Method m, Object[] args) {
		if(!(args[0] instanceof Iterable)){
            throw new BeetlSQLException(BeetlSQLException.MAPPING_ERROR,"期望第一个参数是Iterable");
        }
		sm.insertBatch(entityClass, (List)args[0]);
		return args[0];
	}


}
